<?php
/**
 * CreateTime: 2024/1/16 14:14
 * User:LinQ
 */

namespace App\Http\Controllers\Goods;

use App\Http\Controllers\BasicInterfaceController;
use App\Http\Requests\Goods\GoodsRequest;
use App\Http\Requests\System\ListRequest;
use App\Http\Service\Company\CompanyService;
use App\Http\Service\Goods\ManageGoodsService;

class ManageGoodsController implements BasicInterfaceController
{

    public function getList()
    {
        $request = request()->only('page','page_size','filters','desc');
        (new ListRequest())->check($request);
        (new ManageGoodsService())->getList($request);
    }

    public function getSelect()
    {

    }

    public function getSelectHasPage()
    {

    }

    public function getInfo($id)
    {
        (new ManageGoodsService())->getInfo($id);
    }

    public function create()
    {
        $data = request()->only(
            'goods_name',
            'goods_price',
            'goods_show_image_id',
            'goods_image_ids',
            'goods_simple_name',
            'goods_brand',
            'shipping_location_info',
            'belonging_works',
            'sales_method',
            'sales_method_number',
            'group_id',
            'goods_type_id',
            'goods_describe',
            'goods_stock',
            'stock_start_time',
            'stock_status',
        );
        (new GoodsRequest())->check($data);
        (new ManageGoodsService())->create($data);
    }

    public function enableGoods($id){
        (new ManageGoodsService())->enableGoods($id);
    }

    public function disableGoods($id){
        (new ManageGoodsService())->disableGoods($id);
    }


    public function fakeDelete($id)
    {

    }

    public function fakeDeleteByIds($ids)
    {

    }

    public function delete()
    {

    }

    public function update($id)
    {
        $request = request()->only(
            'goods_name',
            'goods_show_image_id',
            'goods_image_ids',
            'goods_simple_name',
            'goods_brand',
            'shipping_location_info',
            'belonging_works',
            'sales_method',
            'sales_method_number',
            'group_id',
            'goods_type_id',
            'goods_describe',
            'stock_status'
        );
        $request['goods_id'] = $id;
        (new ManageGoodsService())->update($request);
    }

    public function setPrice($goodsId){
        $data = request()->only(
            'goods_price',
            'goods_stock',
        );
        $data['goods_id'] = $goodsId;
        (new GoodsRequest())->scene('setPrice')->check($data);
        (new ManageGoodsService())->setPrice($data);
    }


}
